package com.fengke.dao.model;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang3.builder.ToStringBuilder;

import com.fengke.util.DateUtil;

public class ProductModel extends BaseEntity {
	private static final long serialVersionUID = 6837661917566165812L;
	public enum ProductType {
		/** 商品 */
		Merchandise(0),
		/** 活动 */
		Activities(1);
		private int type;
		ProductType(int type) {
			this.type = type;
		}
		public int getType() {
			return this.type;
		}
	}
	/** 产品类别 */
	private ProductType productType;
	private Integer mproductType;
	/** 商品分类 */
	private ProductCategoryModel productCategoryModel;
	/** 商户 */
	private AdminModel adminModel;
	/** 库存 */
	private Integer stock;
	/** 已分配库存 */
	private Integer allocatedStock;
	/** 库存备注 */
	private String stockMemo;
	/** 全称 */
	private String fullName;
	/** 展示图片 */
	private String image;
	/** 是否为赠品 */
	private Boolean isGift;
	/** 是否上架 */
	private Boolean isMarketable;
	/** 是否列出 */
	private Boolean isList;
	/** 是否置顶 */
	private Boolean isTop;
	/** 市场价 */
	private BigDecimal marketPrice;
	/** 名称 */
	private String name;
	/** 赠送积分 */
	private Long point;
	/** 成人销售价 */
	private BigDecimal price;
	/** 儿童销售价 */
	private BigDecimal childrenPrice;
	/** 拼房价格 */
	private BigDecimal hoursePrice;
	/** 销量 */
	private Long sales;
	/** 页面标题 */
	private String seoTitle;
	/** 页面关键词 */
	private String seoKeywords;
	/** 页面描述 */
	private String seoDescription;
	/** 编号 */
	private String sn;
	/** 服务提供商 */
	private String serviceProvider;
	/** 目的地 */
	private String destination;
	/** 联系电话 */
	private String phone;
	/** 出发地 */
	private String startAddress;
	/** 到期时间 */
	private Date expire;
	private Date beginDate;
	private Date endDate;
	/** 疑似出发时间列表 */
	private String startingDate;
	/** 是否PC端显示 **/
	private Boolean isPCShow;
	/** 是否PC首页轮播展示 **/
	private Boolean isCarousel;
	/** 二维码路径 */
	private String zxingPath;
	/** 排序 */
	private Integer orders;
	/** 不知道是做什么的 */
	private Date stickTime;
	
	private Date goDate;
	/** 风客推荐理由 */
	private String productFeatures;
	/** 产品介绍 */
	private String introduction;
	/** 预定须知 */
	private String feeInclude;
	/** 行程介绍 */
	private String introduction1;
	/** 签证信息 */
	private String visaInfo;
	/** 航班信息 */
	private String flightInfo;
	/** 酒店信息 */
	private String hotelInfo;
	/** 费用说明 */
	private String feeInclude1;
	
	/** 主题查询 */
	private List<String> searchCategoryList = new ArrayList<String>();
	/** 出发地查询 */
	private List<String> searchStartAddressList = new ArrayList<String>();
	/** 目的地查询 */
	private List<String> searchDestinationList = new ArrayList<String>();
	/** 出发时间查询 */
	private List<String> searchStartDateList = new ArrayList<String>();
	
	//hits
	//month_hits_date,month_sales,month_sales_date,score,score_count,total_score
	//week_hits,week_hits_date,week_sales,week_sales_date,has_agreement
	

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}
	
	public String getDefaultDateString(){
		List<Date> arrDate=new ArrayList<Date>();
		if(startingDate!=null){
	         String[] dates=startingDate.split(",");
	         if(dates!=null&&dates.length!=0){
	        	 for(int i=0;i<dates.length;i++){
	        		 if(DateUtil.parseDate(dates[i]).compareTo(DateUtil.addDate(new Date(), -1))==1){
	        			 arrDate.add(DateUtil.parseDate(dates[i]));
	        		 }
	        	 }
	         }
	         return this.getMinDateString(arrDate);
		}
		return null;
	}
	
	public String getGoDateString()
    {
        if(goDate!=null){
        	return DateUtil.formatDate(goDate);
        }
        return null;
    }
	
	private String getMinDateString(List<Date> dates){
		if(dates!=null&&dates.size()!=0){
			Date temp=dates.get(0);
			for(Date d:dates){
				if((d.compareTo(temp)==-1||d.compareTo(temp)==0)){
					temp=d;
				}
			}
				return DateUtil.formatDate(temp);
		}
		return null;
	}
	
	public String getMaxDateStr(){
		List<Date> arrDate=new ArrayList<Date>();
		if(startingDate!=null){
	         String[] dates=startingDate.split(",");
	         if(dates!=null&&dates.length!=0){
	        	 for(int i=0;i<dates.length;i++){
	        		 if(DateUtil.parseDate(dates[i]).compareTo(DateUtil.addDate(new Date(), -1))==1){
	        			 arrDate.add(DateUtil.parseDate(dates[i]));
	        		 }
	        	 }
	         }
	         return this.getMaxDateString(arrDate);
		}
		return null;
	}
	
	private String getMaxDateString(List<Date> dates){
		if(dates!=null&&dates.size()!=0){
			Date temp=dates.get(0);
			for(Date d:dates){
				if((d.compareTo(temp)==1||d.compareTo(temp)==0)){
					temp=d;
				}
			}
				return DateUtil.formatDate(temp);
		}
		return null;
	}

	public ProductCategoryModel getProductCategoryModel() {
		return productCategoryModel;
	}

	public void setProductCategoryModel(ProductCategoryModel productCategoryModel) {
		this.productCategoryModel = productCategoryModel;
	}

	public AdminModel getAdminModel() {
		return adminModel;
	}

	public void setAdminModel(AdminModel adminModel) {
		this.adminModel = adminModel;
	}

	public Integer getStock() {
		return stock;
	}

	public void setStock(Integer stock) {
		this.stock = stock;
	}

	public Integer getAllocatedStock() {
		return allocatedStock;
	}

	public void setAllocatedStock(Integer allocatedStock) {
		this.allocatedStock = allocatedStock;
	}

	public String getStockMemo() {
		return stockMemo;
	}

	public void setStockMemo(String stockMemo) {
		this.stockMemo = stockMemo;
	}

	public String getFullName() {
		return fullName;
	}

	public void setFullName(String fullName) {
		this.fullName = fullName;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public String getIntroduction() {
		return introduction;
	}

	public void setIntroduction(String introduction) {
		this.introduction = introduction;
	}

	public String getIntroduction1() {
		return introduction1;
	}

	public void setIntroduction1(String introduction1) {
		this.introduction1 = introduction1;
	}

	public Boolean getIsGift() {
		return isGift;
	}

	public void setIsGift(Boolean isGift) {
		this.isGift = isGift;
	}

	public Boolean getIsMarketable() {
		return isMarketable;
	}

	public void setIsMarketable(Boolean isMarketable) {
		this.isMarketable = isMarketable;
	}

	public Boolean getIsList() {
		return isList;
	}

	public void setIsList(Boolean isList) {
		this.isList = isList;
	}

	public Boolean getIsTop() {
		return isTop;
	}

	public void setIsTop(Boolean isTop) {
		this.isTop = isTop;
	}

	public BigDecimal getMarketPrice() {
		return marketPrice;
	}

	public void setMarketPrice(BigDecimal marketPrice) {
		this.marketPrice = marketPrice;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Long getPoint() {
		return point;
	}

	public void setPoint(Long point) {
		this.point = point;
	}

	public BigDecimal getPrice() {
		return price;
	}

	public void setPrice(BigDecimal price) {
		this.price = price;
	}

	public BigDecimal getChildrenPrice() {
		return childrenPrice;
	}

	public void setChildrenPrice(BigDecimal childrenPrice) {
		this.childrenPrice = childrenPrice;
	}

	public BigDecimal getHoursePrice() {
		return hoursePrice;
	}

	public void setHoursePrice(BigDecimal hoursePrice) {
		this.hoursePrice = hoursePrice;
	}

	public Long getSales() {
		return sales;
	}

	public void setSales(Long sales) {
		this.sales = sales;
	}

	public String getSeoTitle() {
		return seoTitle;
	}

	public void setSeoTitle(String seoTitle) {
		this.seoTitle = seoTitle;
	}

	public String getSeoKeywords() {
		return seoKeywords;
	}

	public void setSeoKeywords(String seoKeywords) {
		this.seoKeywords = seoKeywords;
	}

	public String getSeoDescription() {
		return seoDescription;
	}

	public void setSeoDescription(String seoDescription) {
		this.seoDescription = seoDescription;
	}

	public String getSn() {
		return sn;
	}

	public void setSn(String sn) {
		this.sn = sn;
	}

	public String getServiceProvider() {
		return serviceProvider;
	}

	public void setServiceProvider(String serviceProvider) {
		this.serviceProvider = serviceProvider;
	}

	public String getDestination() {
		return destination;
	}

	public void setDestination(String destination) {
		this.destination = destination;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getStartAddress() {
		return startAddress;
	}

	public void setStartAddress(String startAddress) {
		this.startAddress = startAddress;
	}

	public String getFeeInclude() {
		return feeInclude;
	}

	public void setFeeInclude(String feeInclude) {
		this.feeInclude = feeInclude;
	}

	public String getFeeInclude1() {
		return feeInclude1;
	}

	public void setFeeInclude1(String feeInclude1) {
		this.feeInclude1 = feeInclude1;
	}

	public Date getExpire() {
		return expire;
	}

	public void setExpire(Date expire) {
		this.expire = expire;
	}

	public Date getBeginDate() {
		return beginDate;
	}

	public void setBeginDate(Date beginDate) {
		this.beginDate = beginDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public String getStartingDate() {
		return startingDate;
	}

	public void setStartingDate(String startingDate) {
		this.startingDate = startingDate;
	}

	public Boolean getIsPCShow() {
		return isPCShow;
	}

	public void setIsPCShow(Boolean isPCShow) {
		this.isPCShow = isPCShow;
	}

	public Boolean getIsCarousel() {
		return isCarousel;
	}

	public void setIsCarousel(Boolean isCarousel) {
		this.isCarousel = isCarousel;
	}

	public String getZxingPath() {
		return zxingPath;
	}

	public void setZxingPath(String zxingPath) {
		this.zxingPath = zxingPath;
	}

	public String getProductFeatures() {
		return productFeatures;
	}

	public void setProductFeatures(String productFeatures) {
		this.productFeatures = productFeatures;
	}

	public Date getStickTime() {
		return stickTime;
	}

	public void setStickTime(Date stickTime) {
		this.stickTime = stickTime;
	}

	public Integer getOrders() {
		return orders;
	}

	public void setOrders(Integer orders) {
		this.orders = orders;
	}

	public Date getGoDate() {
		return goDate;
	}

	public void setGoDate(Date goDate) {
		this.goDate = goDate;
	}

	public List<String> getSearchCategoryList() {
		return searchCategoryList;
	}

	public void setSearchCategoryList(List<String> searchCategoryList) {
		this.searchCategoryList = searchCategoryList;
	}

	public List<String> getSearchStartAddressList() {
		return searchStartAddressList;
	}

	public void setSearchStartAddressList(List<String> searchStartAddressList) {
		this.searchStartAddressList = searchStartAddressList;
	}

	public List<String> getSearchDestinationList() {
		return searchDestinationList;
	}

	public void setSearchDestinationList(List<String> searchDestinationList) {
		this.searchDestinationList = searchDestinationList;
	}

	public List<String> getSearchStartDateList() {
		return searchStartDateList;
	}

	public void setSearchStartDateList(List<String> searchStartDateList) {
		this.searchStartDateList = searchStartDateList;
	}

	public ProductType getProductType() {
		return productType;
	}

	public void setProductType(ProductType productType) {
		this.productType = productType;
	}

	public Integer getMproductType() {
		if(this.productType == null) {
			return null;
		}
		this.mproductType = this.productType.getType();
		return mproductType;
	}

	public void setMproductType(Integer mproductType) {
		this.mproductType = mproductType;
		if(mproductType == null) {
			return ;
		}
		if(mproductType == ProductType.Merchandise.getType()) {
			this.productType = ProductType.Merchandise;
		} else if(mproductType == ProductType.Activities.getType()) {
			this.productType = ProductType.Activities;
		}
	}

	public String getFlightInfo() {
		return flightInfo;
	}

	public void setFlightInfo(String flightInfo) {
		this.flightInfo = flightInfo;
	}

	public String getVisaInfo() {
		return visaInfo;
	}

	public void setVisaInfo(String visaInfo) {
		this.visaInfo = visaInfo;
	}

	public String getHotelInfo() {
		return hotelInfo;
	}

	public void setHotelInfo(String hotelInfo) {
		this.hotelInfo = hotelInfo;
	}
}